<?php
//控制器扩展
class ControllerExt implements Extension
{
    public function before($obj=null)
    {      
    	session_start();
    	/*
    	$type1 = intval($_GET['mobile_app_123']);
    	$type2 = Session::get("mobile_app_123");
    	
    	if($type1 == 1 || $type2 == 1)
    	{
    	    Tiny::app()->setTheme("mobile");
    	    Session::set("mobile_app_123", 1);
    	}
    	else
    	{
    	    Tiny::app()->setTheme("default");
    	}
    	*/
    	
    	
    	//测试平板或者手机端主题
        $clientType = strval(Chips::clientType());
        $mobile=Req::args('mobile');
        if($clientType === 'tablet' || $clientType ==='mobile' || $mobile==1)
        {
        	//Tiny::app()->setTheme("mobile");
        	
        	$con = strval(Req::args('con'));
        	
        	if($con === 'wymobile')
        	{
        		Tiny::app()->setTheme("wymobile");
        	}
        	elseif($con==='mobile')
        	{
        		Tiny::app()->setTheme("mobile");
        	}
        	
        }
        else 
        {
        	Tiny::app()->setTheme("default");
        } 
        
        
        /*****************暂时的**********************/
        /*
        $con = strval(Req::args('con'));
        if($con==='mobile')
        {
            Tiny::app()->setTheme("mobile");
        }
        */
        /*******************************************/
        
        //Tiny::app()->setTheme("default");
        
        
        $config          = Config::getInstance();
        $site            = $config->get('globals');
        $other           = $config->get('other');
        $currency_symbol = isset($other['other_currency_symbol'])?$other['other_currency_symbol']:'￥';
        $currency_unit   = isset($other['other_currency_unit'])?$other['other_currency_unit']:'元';
        $site_logo       = (isset($site['site_logo'])&&$site['site_logo']!='')?$site['site_logo']:'static/images/logo.png';
        $site_name       = isset($site['site_name'])?$site['site_name']:'TinyShop商城';
        $site_icp        = isset($site['site_icp'])?$site['site_icp']:'鲁ICP备00000100号';

        $obj->assign('currency_symbol',$currency_symbol);
        $obj->assign('currency_unit',$currency_unit);
        $obj->assign('site_logo',$site_logo);
        $obj->assign('site_name',$site_name);
        $obj->assign('site_icp',$site_icp);
    }
    public function after($obj=null)
    {
    }
}
